﻿// /////////////////////////////////// 
//  
//  
//      WiseLink CCF2.0 
//     (c)Copyright 2001-2010 WiseLink Xiaojun (David) Chen 
//        Authored and Owned Xiaojun (David) Chen 
//        All Right Reserved
//  
// /////////////////////////////////// 

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using CCF20Model;
using WiseLink.RDS.Resource;
using CCF20Model;
using CCF20Module;

namespace CCF20.CustomerState
{
    public interface ICustomerState
    {
        void runWillRepair();
        void runReject();
        void runGiveup();
        void runLocation();
        void runRestore();
        void runRemoveUrgent();
        string StateName { get; set; }
        void setState(ICustomerState customerState);
    }

    public class CustomerStateBase : ICustomerState
    {
        protected Vehicle vehicle;
        protected VehicleModel vehicleModel;
        public string StateName { get; set; }
        public siteModel locationModel { get; set; }
        public CustomerStateBase(Vehicle v, VehicleModel model)
        {
            vehicle = v;
            vehicleModel = model;
        }
        public virtual void runWillRepair()
        {
            vehicle.LastContactResult = WiseLinkRDSStatus.Contact_WillRepair;
            vehicleModel.VehicleRepairEnd(vehicle, 0, WiseLinkRDSStatus.Contact_WillRepair);
        }

        public virtual void runReject()
        {
            vehicle.LastContactResult = WiseLinkRDSStatus.Contact_Reject;
            vehicleModel.DeclineCustomer(vehicle,WiseLinkRDSStatus.Contact_Reject);
        }

        public virtual void runGiveup()
        {
            vehicle.LastContactResult = WiseLinkRDSStatus.Contact_Giveup;
            vehicleModel.GiveUpCustomer(vehicle);
        }
        public virtual void runLocation()
        {

            LoggerHelper.LogCCF20(string.Format("查询位置经度={0}, 维度={1}", locationModel.Latitude, locationModel.Longitude));
            HelpMap map = new HelpMap(locationModel);
            map.ShowDialog();
        }
        public virtual void runRestore()
        {
            vehicle.LastContactResult = WiseLinkRDSStatus.Contact_NotContactYet;
            vehicleModel.RestoreCustomer(vehicle);
            
        }
        public virtual void runRemoveUrgent()
        {
            if (vehicle.UrgentCount > 0 && Utility.ShowConfirmation(Message.Care_RemvoeUrgent_Confirm))
            {
                vehicleModel.RemoveUrgent(vehicle);
            }
        }

        public virtual void setState(ICustomerState customerState)
        {
            throw new NotImplementedException();
        }
    }
}
